package framework.resolver;

import org.openems.entity.Entity;
import org.openems.entity.Key;

import framework.AccessorHelper;

public 	class GreaterResolver implements UnitResolver {
	private Key thisKey;
	private Key lessKey;
	private boolean changeable = true;

	public GreaterResolver(Key thisKey, Key lessKey) {
		this.thisKey = thisKey;
		this.lessKey = lessKey;
	}
	
	@Override
	public void resolve(Entity oldEntity, Entity newEntity, AccessorHelper helper) {
		Double thisValue = helper.getDoubleValue(this.thisKey);
		
		if (thisValue < helper.getDoubleValue(lessKey)) {
			if (this.changeable ) {
				helper.setDoubleValue(lessKey, thisValue);
			}
			else {
				helper.setDoubleValue(thisKey, helper.getDoubleValue(lessKey));
			}
		}
	}
};	